import ajax, { instance } from '@/utils/request'

// 用户登录获取token信息
export const userLogin = (mobile, code) => {
  return instance({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    // 如果是接口约定是body传参的话使用data
    data: {
      mobile: mobile,
      code: code
    }
  })
}
// 关注用户
export const focusAuthor = (target) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target: target
    }
  })
}
// 取消关注
export const NofocusAuthor = (target) => {
  return ajax({
    method: 'DELETE',
    url: '/app/v1_0/user/followings/' + target
  })
}
// 获取用户自己的信息
export const getUser = () => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/user'
  })
}
// 获取用户个人信息
export const userGetInfo = () => {
  return ajax({
    method: 'get',
    url: '/app/v1_0/user/profile'
  })
}
// 修改个人信息
export const updateUserInfo = obj => {
  return ajax({
    method: 'PATCH',
    url: '/app/v1_0/user/profile',
    data: obj
  })
}
// 上传头像数据 fromdata
export const updatePhoto = obj => {
  return ajax({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data: obj
  })
}
